package thesis;
import java.awt.Container;
import java.awt.Font;
import java.awt.GraphicsEnvironment;
import java.awt.GridLayout;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;

import com.mongodb.DBObject;


public class MoreInfoFrame extends JFrame{
	private static final long serialVersionUID = 1L;
	
	public MoreInfoFrame(DBObject tweet) {
		super("More Information"); 
		
		InternTweetInfoExtractor infoExtr = new InternTweetInfoExtractor(tweet);

		setBounds(0, 0, GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds().width, GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds().height);
		setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
		
		Container c = this.getContentPane();
		c.setLayout(new GridLayout(9, 1));
		
		Font font = new Font("Arial", Font.PLAIN, 18);
		
		JPanel panelId = new JPanel();
		JLabel id = new JLabel("ID: " + infoExtr.getId());
		id.setFont(font);
		panelId.add(id);
		
		c.add(panelId);
		
		JPanel panelText = new JPanel();
		JLabel text = new JLabel("TEXT: " + infoExtr.getText());
		text.setFont(font);
		panelText.add(text);
		
		c.add(panelText);
		
		JPanel panelQuality = new JPanel();
		JLabel quality = new JLabel("QUALITY: " + infoExtr.getQuality());
		quality.setFont(font);
		panelQuality.add(quality);
		
		c.add(panelQuality);
		
		JPanel panelInfo = new JPanel();
		JLabel info = new JLabel("INFO: " + infoExtr.getInfo());
		info.setFont(font);
		panelInfo.add(info);
		
		c.add(panelInfo);
		
		JPanel panelRels = new JPanel();
		int numberOfConcepts = infoExtr.getRelevanceList().size();
		
		panelRels.setLayout(new GridLayout(numberOfConcepts, 1));
		
		for(Relevance r : infoExtr.getRelevanceList()){
			JPanel panelRelevance = new JPanel();
			JLabel rel = new JLabel("CONCEPT: " + r.getConceptId() + " --> RELEVANCE: " + r.getRelevance());
			rel.setFont(font);
			panelRelevance.add(rel);
			panelRels.add(panelRelevance);
		}
		
		c.add(panelRels);
		
		
		JPanel panelCoordinates = new JPanel();
		JLabel coordinates = null;
		if (infoExtr.hasCoordinates()){
			coordinates = new JLabel("COORDINATES --> Latitude: " + infoExtr.getLatitude() + "; Longitude: " + infoExtr.getLongitude());
		}
		else{
			coordinates = new JLabel("COORDINATES: null");
		}
		
		coordinates.setFont(font);
		panelCoordinates.add(coordinates);
		
		c.add(panelCoordinates);
		
		JPanel panelLocation = new JPanel();
		JLabel location = new JLabel("LOCATION CATEGORY: " + infoExtr.getLocationCategory());
		location.setFont(font);
		panelLocation.add(location);
		
		c.add(panelLocation);
		
		JPanel panelTime = new JPanel();
		JLabel time = new JLabel("TIME CATEGORY: " + infoExtr.getTimeCategory());
		time.setFont(font);
		panelTime.add(time);
		
		c.add(panelTime);
		
		JPanel panelCluster = new JPanel();
		JLabel cluster = new JLabel("CLUSTER: " + FSModule.readClusterWithTweetId(infoExtr.getId()));
		cluster.setFont(font);
		panelCluster.add(cluster);
		
		c.add(panelCluster);
	}
}
